package com.example.base.demo.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.support.PropertySourceFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 将
 * @author TangDan
 * @version 1.0
 * @since 2023/3/2
 *
 *

 * name：，不指定Spring
 * value：
 * ignoreResourceNotFound：没有找到，默认false，4.0版本加入
 * encoding：，默认UTF-8 4.3版本才加入
 * factory：，默认：PropertySourceFactory.class 4.3版本才加入，如果是之前的版本就需要手动注入配置文件解析Bean
 * 接下来就使用@PropertySource来加载.properties与.xml配置文件。这里模拟连接MySQL数据库。
 */

@Component
@PropertySource(value = "classpath:db.properties")
@ConfigurationProperties(prefix = "db")
public class Db {

    String host;

    Integer port;
    String username;
    String password;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
